﻿using GN.Pay.TradeChannel.DefaultImpl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.Transfers
{
    /// <summary>
    /// 转账申请结果
    /// </summary>
    [Serializable]
    public class TransfersApplyResult : ATradeChannelResult, ITransfersApplyResult
    {
        public TransfersApplyResult() : base(null)
        {
        }
        public TransfersApplyResult(IChannel channel) : base(channel)
        {
        }

        /// <summary>
        /// 结果状态
        /// </summary>
        public TradeApplyResultState ResultState { get; set; }

        /// <summary>
        /// 结果状态消息
        /// </summary>
        public string ResultStateMessage { get; set; }

        /// <summary>
        /// 交易号
        /// </summary>
        public string TradeNo { get; set; }

        /// <summary>
        /// 转账费用
        /// </summary>
        public decimal TransfersFee { get; set; }

        /// <summary>
        /// 转账金额
        /// </summary>
        public decimal TransfersMoney { get; set; }

        /// <summary>
        /// 转账编号
        /// </summary>
        public string TransfersNo { get; set; }

        /// <summary>
        /// 转账时间
        /// </summary>
        public DateTime? TransfersTime { get; set; }

        /// <summary>
        /// 验证
        /// </summary>
        public void Validation()
        {
            if (this.TransfersFee < 0)
            {
                this.ThrowChannelValidationException
                    ("TransfersFee 小于零");
            }
            if (this.TransfersMoney <= 0)
            {
                this.ThrowChannelValidationException
                    ("TransfersMoney 小于或等于零");
            }
            if (string.IsNullOrWhiteSpace(this.TransfersNo))
            {
                this.ThrowChannelValidationException
                    ("TransfersNo 为 null 或空白");
            }
            if (this.TradeNo == null)
            {
                this.TradeNo = "";
            }
        }
    }
}
